package com.gagakuai.demo.refrence;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/*
 * @program: settement
 * @description:
 * @author: houhong
 * @create: 2022-11-12 19:57
 */
public class MainTest2 {

    public static void main(String[] args) {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        //创建一个BeanFactoryPostProcessor：BeanFactory后置处理器
       /* context.addBeanFactoryPostProcessor(beanFactory -> {
            if (beanFactory instanceof DefaultListableBeanFactory) {
                //将allowRawInjectionDespiteWrapping设置为true
                ((DefaultListableBeanFactory) beanFactory).setAllowRawInjectionDespiteWrapping(true);
            }
        });*/
        context.register(MainConfig3.class);
        context.refresh();



        ServiceA service1 = context.getBean(ServiceA.class);
        ServiceB service2 = context.getBean(ServiceB.class);

        System.out.println("----A-----");
        service2.m1(); //@
        System.out.println("----B-----");
        service1.m1(); //@2
        System.out.println("----C-----");
        System.out.println(service2);
        System.out.println(service2.getServiceA() == service1);
    }
}